
/*
 *  ======== plio.h ========
 * 
 *  Header file for plio.c, which allows a PIP to interface to an
 *  LIO. As implemented only one LIO driver may be used, and may only be
 *  used with a single input and single output channel. You may modify
 *  this code to enable more channels and drivers.
 *
 *  See the comments below for how to configure a DSP/BIOS application
 *  which uses this code.
 */

#ifndef PLIO_
#define PLIO_

#include <pip.h>

#include <lio.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief 
*/
typedef struct PLIO_Attrs {
    String name;
    Ptr openArgs;
} PLIO_Attrs;

/**
* @brief 
*/
extern PLIO_Attrs PLIO_ATTRS;	// default PLIO_Attrs structure

/**
* @brief 
*/
typedef struct PLIO_Obj
{
    Uns		submitCount;	// keep track of frames submitted
    Uns		submitLimit;	// max frames controller can accept

    LIO_Fxns	*fxns;		// PLIO interface functions

    PIP_Curdesc	*curdesc;	// used to access pipe on submit side
    PIP_Handle	pip;		// pointer to associated pipe

    Ptr		controller;	// pointer to device-specific state object
} PLIO_Obj, *PLIO_Handle;

/*
 * PLIO_ctrl() passes parameters straight through to the controller
 */
#define PLIO_ctrl(plio, cmd, args) \
	(plio)->fxns->ctrl((plio)->controller, cmd, args)

/*
 * PLIO_new() must be called to initialize the I/O prior to any
 * transfers occuring. Pass in the pointer to the PLIO object and pointer
 * to PIP object to associate with that channel. The last argument is for
 * various attributes including a generic argument to be passed to LIO 
 * open, it may be NULL. You would typically call PLIO_new() from main.
 */
extern Void PLIO_new(
    PLIO_Handle plio, PIP_Handle pip, LIO_Mode mode, LIO_Fxns *fxns,
    PLIO_Attrs *attrs
);

/*
 *  PLIO_txPrime should be configured as the writer notify
 *  function for output pipes.
 *  PLIO_rxPrime should be configured as the reader notify
 *  function of input pipes.
 */
extern Void PLIO_rxPrime(PLIO_Handle plio);
extern Void PLIO_rxStart (PLIO_Handle plio, Uns frameCount);
extern Void PLIO_txPrime(PLIO_Handle plio);
extern Void PLIO_txStart (PLIO_Handle plio, Uns frameCount, Uns initialValue);

#ifdef __cplusplus
}
#endif /* extern "C" */

#endif /* PLIO_ */


